package com.testAll;

import com.alibaba.fastjson.JSON;
import com.core.comment.StringUtil;
import com.core.jdbc.SqlHelper;
import com.core.util.CommonUtil;

import javax.sound.midi.Soundbank;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.SimpleFormatter;

/**
 * @author liujian
 * @email v_vjiannliu@tencent.com
 * @date 2022/3/15 15:30
 */
public class testWecarDeviceId {
    public static void main(String[] args) throws Exception {
        test3();
    }

    public static void test2() throws Exception {


        String dcacheJson = CommonUtil.readJsonFile("C:\\Users\\v_vjiannliu\\Desktop\\useraccunew\\data\\wecarddtest");

        List<String> listwecardd = Arrays.asList(dcacheJson.split("#").clone());

        List<String> listwecardd2 = new ArrayList<>();
        listwecardd.forEach(item -> {
            listwecardd2.add(item.trim());
        });
        System.out.println(JSON.toJSONString(listwecardd2));
        List<String> sqls = new ArrayList<>();
        for (String item : listwecardd2) {
            if (StringUtil.isNotBlack(item)) {
                String[] array = item.split("\\|");
                String sqlUnit = "UPDATE wecardd2 SET deviceid='" + array[2] + "' where wecarid='" + array[0] + "' ;";
                sqls.add(sqlUnit);
            }
        }
        SqlHelper.sqlOperateList(sqls);

    }

    public static void test() throws SQLException {
        String sql = "SELECT * from wecardd2;";
        List<Map<String, Object>> list = SqlHelper.queryMapList(sql, new HashMap<>());
        List<String> listWecarid = new ArrayList<>();
        List<List<String>> listWecaridALl = new ArrayList<>();
        int i = 1;
        int passIndex = 1;
        for (Map<String, Object> map : list) {
            String wecarid = CommonUtil.toString(map.get("wecarid"));
            if (StringUtil.isNotBlack(wecarid)) {
                listWecarid.add(wecarid);
            }
            if (i % 400 == 0) {
                passIndex++;
                System.out.println(i + "++++" + passIndex);
                listWecaridALl.add(new ArrayList<>(listWecarid));
                System.out.println(JSON.toJSONString(listWecarid));
                listWecarid = new ArrayList<>();
                System.out.println();
            }
            i++;

        }
        System.out.println("++++" + (passIndex + 1));
        System.out.println(JSON.toJSONString(listWecarid));

        System.out.println();
        System.out.println("ok");

        //JSON.toJSONString(listWecaridALl);



    }
    public static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String formatNow() {  /**获取格式化当前日期的表达式**/
        return DATEFORMAT.format(Calendar.getInstance().getTimeInMillis());
    }

    public static void test3() throws ParseException {
        Date date=DATEFORMAT.parse("2022-05-25 00:00:00");
        System.out.println(date);
        System.out.println(date.getTime());

        Date date2=DATEFORMAT.parse("2022-05-25 23:00:00");
        System.out.println(date2);
        System.out.println(date2.getTime());

        String ddd=DATEFORMAT.format(new Date(1653463449000l));
        System.out.println(ddd);
    }


}
